//
//  CGQyunweiCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/4/7.
//  Copyright © 2021 叁拾叁. All rights reserved.
//


import UIKit


class CGQyunweiCell: SYBaseCell {

    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor.white
        v.layer.cornerRadius = 5.autoWidth()
        v.layer.masksToBounds = true
        return v
    }()
    
    let title: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x333333)
        v.font = 17.autoFontSize()
        v.text = "设备离线"
        return v
    }()
    
    let subTitle: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x666666)
        v.font = 14.autoFontSize()
        v.text = "修改设备信息:畜禽测试设备, 设备id:200325000001, 所属项目: 公司测试设备勿删"
//        v.numberOfLines = 0
        return v
    }()
    
    let time: UILabel = {
        let v:UILabel = UILabel()
        v.textColor = UIColor(hex: 0x999999)
        v.font = 12.autoFontSize()
//        v.text = "3月10日"
        return v
    }()
    
    let pic: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("yunwei_icon_b")
        return v
    }()
    
    let arrow: UIImageView = {
        let v: UIImageView = UIImageView()
        v.sy_name("arrow_gray")
        return v
    }()
    

    public func configureView(model: NSYuweiRecordsModel) {
        title.text = model.businessName
        time.text = model.createDate
        subTitle.text = model.remarks ?? "暂无内容"
        
        if model.businessName == "添加设备" {
            pic.sy_name("yunwei_icon_b")

        }else{
            pic.sy_name("yunwei_icon_r")

        }
        
//        title.text = model.name
//        if let p = model.imgPath {
//            pic.kf.setImage(with: URL(string: IMGIP+p))
//        }
        
    }
    
    override func initViews() {
        
        self.backgroundColor = .clear
        addSubview(bgView)
        addSubview(pic)
        addSubview(title)
        addSubview(subTitle)
        addSubview(arrow)
        addSubview(time)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(10))
            make.right.equalToSuperview().offset(autoWidth(-10))
            make.bottom.equalToSuperview()
        }
        pic.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(10))
            make.width.equalTo(7.5.autoWidth())
//            make.height.equalTo(84.autoWidth())
            make.bottom.equalToSuperview()
        }
        title.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(30.autoWidth())
            make.left.equalToSuperview().offset(autoWidth(27))
            make.right.equalToSuperview().offset(autoWidth(-12.0))
            make.height.equalTo(17.autoWidth())
        }
        subTitle.snp.makeConstraints { (make) in
            make.top.equalTo(title.snp.bottom).offset(5)
            make.bottom.equalToSuperview().offset(-20.autoWidth())
            // MARK: - 距离底部的长度为20，当21时不能换行，特此mark
            make.left.equalToSuperview().offset(autoWidth(27))
            make.right.equalToSuperview().offset(-30.autoWidth())
        }
        arrow.snp.makeConstraints { (make) in
//            make.top.equalToSuperview().offset(57.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-20.0))
            make.width.equalTo(8.autoWidth())
            make.height.equalTo(14.autoWidth())
            make.centerY.equalTo(bgView.snp.centerY)
        }
        time.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(26.autoWidth())
            make.right.equalToSuperview().offset(autoWidth(-22.0))
            make.height.equalTo(11.autoWidth())
        }
        
        
    }
}


